<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.thymeleaf.org"
      layout:decorator="layout/master">
<body layout:fragment="content" class="bgwh">
<div th:replace="layout/layout::center_zy_search_top_box('账户安全')"></div>
<script src="/js/layer/layer.js"></script>
<!-- 内容框 -->
<div class="zy_module-content">
    <div class="vip_user_info_mima">
        <form>
            <div class="jiben">
                <div><span>原密码</span><input type="password" id="oldPassword" placeholder="请输入原密码"></div>
                <div><span>新密码</span><input type="password" id="newPassowrd" placeholder="请输入新密码"></div>
                <div><span>确认密码</span><input type="password" id="confirmNewPassword" placeholder="请再次输入新密码"></div>
                <button type="button" onclick="modify()">确认修改</button>
            </div>
        </form>
    </div>
</div>
<script>
    function modify() {
        if (!window.confirm("确认修改密码？")) {
            return;
        }
        var oldPassword = $("#oldPassword").val();
        var newPassowrd = $("#newPassowrd").val();
        var confirmNewPassword = $("#confirmNewPassword").val();
        if (oldPassword.length < 6) {
            layer.msg("原密码错误，请重新输入");
            return;
        }
        if (newPassowrd.length < 6 || confirmNewPassword.length < 6) {
            layer.msg("新密码格式错误，请重新输入");
            return;
        }
        if (newPassowrd != confirmNewPassword) {
            layer.msg("两次新密码不一至，请重新输入");
            return;
        }
        $.post("/ajax/center/userinfopwd", {
            oldPassword: oldPassword,
            newPassowrd: newPassowrd,
            confirmNewPassword: confirmNewPassword
        }, function (d) {
            if (d.code == 0) {
                layer.msg("修改成功");
            } else {
                layer.msg(d.msg);
            }
        })
    }
</script>
</body>
</html>